import 'package:flutter/material.dart';
import 'package:xbaistack/common/toast.dart';

class ToastPage extends StatefulWidget {
  const ToastPage({super.key});

  @override
  State<ToastPage> createState() => _ToastPageState();
}

class _ToastPageState extends State<ToastPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Toast Page")),
      body: Center(
        child: Column(
          children: [
            ElevatedButton(
              child: const Text("显示 Toast"),
              onPressed: () {
                Toast.showSuccess("Toast 提示");
              },
            ),
            ElevatedButton(
              child: const Text("显示 loading提示"),
              onPressed: () {
                final cancel = Toast.showLoading();
                Future.delayed(const Duration(seconds: 1), () {
                  cancel();
                });
              },
            ),
            ElevatedButton(
              child: const Text("显示 notify 提示"),
              onPressed: () {
                final cancel = Toast.showNotification(
                  title: "通知标题",
                  subtitle: "这是一个通知消息",
                );
              },
            ),
             ElevatedButton(
              child: const Text("警告 提示"),
              onPressed: () {
                final cancel = Toast.showWarning('message');
              },
            ),
          ],
        ),
      ),
    );
  }
}
